#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Copyright © 启明星辰 版权所有
# @Time    : 2023/4/10 11:50
# @Author  : 胡浩浩
# @Email   : hu_haohao@venusgroup.com.cn
# @File    : start.py
# @IDE     : PyCharm
# @description :
# Import necessary libraries
import uvicorn
from pywebio import config
from pywebio.platform.fastapi import asgi_app

from backend.app.api import app
from frontend.components.auto_test.login_manage import html_login_manage
from frontend.components.test_report.report_manage import html_show_report
from frontend.components.util_tools.api_test import html_show_api_test
from frontend.components.auto_test.case_convert import html_curl_2_yaml
from frontend.components.auto_test.run_test_case import html_case_exec
from frontend.components.sys_manage.environment import html_show_environment
from frontend.components.sys_manage.server_manage import html_show_server
from frontend.components.util_tools.chart_gpt import html_chart_gpt
from frontend.components.util_tools.data_encode_decode import html_data_encode_decode
from frontend.components.util_tools.data_extract import html_show_data_extract
from frontend.components.util_tools.global_variable import html_show_variables
from frontend.components.util_tools.show_funcs import html_show_funcs
from frontend.menus import show_menus

css = """
.container {
    margin-top: 0;
    max-width: 100%;
    margin-left: 0px;
    margin-top: 0px;
    background-color: #FFFCFB;
    background-image: null;
    background-size: 100% 100%;
}
"""
config(css_style=css)

app.mount("/menus", asgi_app(show_menus, cdn=False))
app.mount("/chartgpt", asgi_app(html_chart_gpt, cdn=False))
app.mount("/data_encode", asgi_app(html_data_encode_decode, cdn=False))
app.mount("/data_extract", asgi_app(html_show_data_extract, cdn=False))
app.mount("/show_func", asgi_app(html_show_funcs, cdn=False))
app.mount("/variables", asgi_app(html_show_variables, cdn=False))
app.mount("/show_environment", asgi_app(html_show_environment, cdn=False))
app.mount("/show_server", asgi_app(html_show_server, cdn=False))
app.mount("/api_test", asgi_app(html_show_api_test, cdn=False))
app.mount("/case_convert", asgi_app(html_curl_2_yaml, cdn=False))
app.mount("/case_exec", asgi_app(html_case_exec, cdn=False))
app.mount("/login_manage", asgi_app(html_login_manage, cdn=False))
app.mount("/reports_list", asgi_app(html_show_report, cdn=False))

if __name__ == '__main__':
    uvicorn.run(app, host="127.0.0.1", port=8081)
